package com.osce.ex.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.csce.domain.entity.exam.ExExamRecord;
import com.csce.domain.entity.exam.vo.ExExamQuestion;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 考试记录Mapper接口
 *
 * @author zzx
 * @since 2023-08-10
 */
@Repository
public interface ExExamRecordMapper extends BaseMapper<ExExamRecord> {

    /**
     * 查询考试记录
     *
     * @param id 考试记录主键
     * @return 考试记录
     */
    ExExamRecord selectExExamRecordById(Long id);

    /**
     * 查询考试记录列表
     *
     * @param exExamRecord 考试记录
     * @return 考试记录集合
     */
    List<ExExamRecord> selectExExamRecordList(ExExamRecord exExamRecord);

    /**
     * 新增考试记录
     *
     * @param exExamRecord 考试记录
     * @return 结果
     */
    int insertExExamRecord(ExExamRecord exExamRecord);

    /**
     * 修改考试记录
     *
     * @param exExamRecord 考试记录
     * @return 结果
     */
    int updateExExamRecord(ExExamRecord exExamRecord);

    /**
     * 删除考试记录
     *
     * @param id 考试记录主键
     * @return 结果
     */
    int deleteExExamRecordById(Long id);

    /**
     * 批量删除考试记录
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    int deleteExExamRecordByIds(Long[] ids);

    Set<Long> selectAppointExamIds(@Param("userId") Long userId);

    int insertExRecordQuestion(@Param("list") List<ExExamQuestion> examQuestionList);

    List<Long> selectUserIdsByExam(@Param("examId") Long examId);

    int batchExExamRecord(@Param("list") List<ExExamRecord> exExamRecords);

    @MapKey("questionId")
    Map<Long, ExExamQuestion> selectRecordQuestions(@Param("ex_id") Long exId);
}
